package giab.weixin.web.util;

import java.io.BufferedInputStream;

import javax.servlet.http.HttpServletRequest;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

@Component 
public class RequestExecuteData {
	
	private Logger logger = LoggerFactory.getLogger(RequestExecuteData.class);
	public RequestExecuteData(){
		logger.debug("初始化");
	}
	public String getPostData(HttpServletRequest request) {
		StringBuffer message = new StringBuffer();
		int iRead;
		try {
			BufferedInputStream buf = new BufferedInputStream(request.getInputStream());
			byte[] buffer = new byte[1024];
			while ((iRead = buf.read(buffer)) != -1) {
				message.append(new String(buffer, 0, iRead, "UTF-8"));
			}
		} catch (Exception e) {
			// TODO: handle exception
			logger.debug(e.getMessage());
			return "";
		}
		return message.toString();

	}

}
